﻿#ifndef FTITLEBAR_H
#define FTITLEBAR_H

#include <QWidget>
#include <QPushButton>
#include <QStyle>
#include <QResizeEvent>

#include <QWKWidgets/widgetwindowagent.h>

namespace Ui {
class FTitleBarWin;
class FTitleBarMac;
}

// 是否使用Mac风格的标题栏？
#define USE_MAC 0

#if USE_MAC
#define UiFTitleBar Ui::FTitleBarMac
#else
#define UiFTitleBar Ui::FTitleBarWin
#endif



class FTitleBar : public QWidget
{
    Q_OBJECT

public:
    enum DefaultButton {
        Close,
        Max,
        Min,

        Icon,

    _Count
    };

    explicit FTitleBar(QWidget *parent = nullptr);
    ~FTitleBar();

    void setIcon(const QIcon& icon);
    void setTitle(const QString& title);

    QPushButton* addStandardButton(const QIcon& icon);
    QPushButton* addStandardButton(const QString& text);
    void addStandardButton(QPushButton* btn);
    void addCustomWidget(QWidget* wgt);

    void setMaxIcon(bool isMaxIcon=true);
    void setWidgetVisible(uint16_t wId, bool en=true);

public slots:
    void onParentMaximized(bool isMax);

protected:
    void setBtnStdIcon(QPushButton* btn, QStyle::StandardPixmap stdIcon);

private slots:
    void resizeEvent(QResizeEvent* e) override;


    void on_btnMax_clicked();

    void on_btnMin_clicked();

    void on_btnClose_clicked();

private:
    UiFTitleBar* ui;
    QWK::WidgetWindowAgent* m_agent;
};

#endif // FTITLEBAR_H
